# 实数二分模板
# ans = realSqrt(x, 1e-6)
# 如果要求4位小数，就多算2~4位，到1e-6或1e-8，保证精确
def realSqrt(x, eps=1e-6):
    left, right = 0, x
    while right - left > eps:
        mid = (left + right) / 2
        if mid * mid <= x:
            left = mid
        else:
            right = mid
    return right


class Solution:
    def mySqrt(self, x: int) -> int:
        return math.floor(realSqrt(x))